<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:55:"D:\Code\lvyou/application/admin\view\travels\index.html";i:1534477527;s:55:"D:\Code\lvyou\application\admin\view\public\header.html";i:1532913947;s:55:"D:\Code\lvyou\application\admin\view\public\footer.html";i:1532913947;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo config('WEB_SITE_TITLE'); ?></title>
    <link rel="stylesheet" href="/static/mui/css/iconfont.css">
    <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/static/admin/css/animate.min.css" rel="stylesheet">
    <link href="/static/admin/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="/static/layui/css/layui.css" rel="stylesheet">
    <link href="/static/admin/css/admin.css" rel="stylesheet">
    <script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <style type="text/css">
        .long-tr th {
            text-align: center
        }

        .long-td td {
            text-align: center
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>游记列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->


            <form class="layui-form" action="" method="post">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label style="width: 95px;" class="layui-form-label">用户昵称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="nickname" lay-verify="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">目的地</label>
                        <div class="layui-input-inline">
                            <input type="text" name="address" id="date" lay-verify="" autocomplete="off"
                                   class="layui-input" lay-key="1">
                        </div>
                    </div>
                    <button type="submit" class="btn btn-primary" lay-submit lay-filter="search">
                        <i class="fa fa-search"></i> 搜索
                    </button>

                </div>
            </form>
            <!--搜索框结束-->
            <div class="example-wrap">
                <div class="example">
                    <table lay-filter="demo">
                        <thead>
                        <tr>
                            <th lay-data="{field:'id', width:100}">id</th>
                            <th lay-data="{field:'nickname'}">用户昵称</th>
                            <th lay-data="{field:'title', width:150, sort:true}">标题</th>
                            <th lay-data="{field:'create_time'}">发布时间</th>
                            <th lay-data="{field:'travel_model'}">出游方式</th>
                            <th lay-data="{field:'address'}">目的地</th>
                            <th lay-data="{field:'action'}">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php if($data): foreach($data as $v): ?>
                        <tr>
                            <td><?php echo $v['id']; ?></td>
                            <td>
                                <?php if(($v['member_id'])): ?>
                                <?php echo $v['member_id']['nickname']; endif; ?>
                            </td>
                            <td><?php echo $v['title']; ?></td>
                            <td><?php echo $v['create_time']; ?></td>
                            <td><?php echo $v['travel_model']; ?></td>
                            <td>
                                <?php if(($v['address'])): foreach($v['address'] as $k1=>$v1): ?>
                                    <?php echo $v1['value']; ?><br>
                                    <?php endforeach; endif; ?>

                            </td>

                            <td>
                                <button data-id="<?php echo $v['id']; ?>" class="layui-btn layui-btn-xs member-show">查看详情</button>
                                <!--<button data-id="<?php echo $v['id']; ?>" class="layui-btn layui-btn-xs edit">编辑</button>-->
                                <button data-id="<?php echo $v['id']; ?>" class="layui-btn layui-btn-xs member-del">删除</button>
                            </td>
                        </tr>
                        <?php endforeach; endif; ?>
                        </tbody>
                    </table>
                    <?php if(($data)): ?>
                    <?php echo $data->render(); endif; ?>

                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
<div style="display: none" id="show">
    <div class="layui-form-item">
        <label class="layui-form">标题：</label>
        <label class="layui-form title"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">出游方式：</label>
        <label class="layui-form travel-model"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">用户名：</label>
        <label class="layui-form name"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">旅行开始时间：</label>
        <label class="layui-form start_date"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">旅行结束时间：</label>
        <label class="layui-form end_date"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">人员关系：</label>
        <label class="layui-form relationship"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">审核状态：</label>
        <label class="layui-form is_show"></label>
    </div>
</div>
<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/static/admin/js/lunhui.js"></script>
<script src="/static/layui/layui.all.js"></script>

<script>
    var table = layui.table;
    //转换静态表格
    table.init('demo', {
        height: 315 //设置高度
        , limit: 10 //注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
        //支持所有基础参数
    });
    //删除
    $('.member-del').click(function () {
        //获取用户id
        var obj = $(this);
        var id = $(this).attr('data-id');
        layer.confirm('是否确认删除该用户？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.post('/admin/travels/del', {id: id}, function (data) {
                console.log(data);
                if (data.code == 200) {
                    layer.msg('已删除', {icon: 1});
                    $(obj).parent().parent().parent().remove();
                } else {
                    layer.msg(data.msg, {icon: 2});
                }
            }, 'json');
        }, function () {
        });
    });
    //查看详情
    $('.member-show').click(function () {
        var id = $(this).attr('data-id');
        if(id){
            $.post('/admin/travels/get_travel',{id:id},function (data) {
                console.log(data);
                if(data.code == 200){
                    $('.title').html(data.data.title);
                    $('.name').html(data.data.member_id.nickname);
                    $('.start_date').html(data.data.start_date);
                    $('.end_date').html(data.data.end_date);
                    $('.relationship').html(data.data.relationship);
                    $('.travel-model').html(data.data.travel_model);
                    var state;
                    if(data.data.is_show == 0){
                        state = '未审核';
                    }else if(data.data.is_show == 1){
                        state = '通过';
                    }else if(data.data.is_show == 2){
                        state = '未通过';
                    }
                    $('.is_show').html(state);
                    show_tpl();
                }else {
                    layer.msg(data.msg, {icon: 2});
                }
            });
        }else {
            layer.msg('id为空', {icon: 2});
        }
       //
    });

    //查看详情弹出层
    function show_tpl() {
        layer.open({
            type: 1,
            title: '游记详情',
            closeBtn: false,
            btn: ['关闭'],
            skin: 'layui-layer-rim', //加上边框
            area: ['420px', '420px'], //宽高
            content: $('#show'),
            end: function () {
                $('#show').css('display', 'none');
            }
        });
    }
</script>


</body>
</html>